﻿<?php
    @session_start();
    include("template/head.php");
	
	
	$sql = "SELECT * FROM `st_attr_entree` WHERE id_article =".$_GET["id_article"]." AND qte <> 0";
	$obj = new Mysql ();
	$result = mysql_query($sql);

    //selectionner la réference et la photo de l'article 
    $s = "select * from st_article where id_article=".$_GET["id_article"];
    $r = mysql_query($s);
    while ($d=mysql_fetch_array($r)) {
        $REFARICLE=$d["ref_article"];
        $QT_AU_STOCK=$d["Quantite"];
        $PHOTOARTICLE=$d["photo_name"];
        $DESIGNATION=$d["designation"];
        $price=$d["prix"];
		
    }
?>
<style type="text/css">
    #example_filter label input{
        height: 27px;
    }
</style>
    <div class="container-fluid">
        <div class="row-fluid">
                
        <?php include("template/menu_left.php") ;
		
                if ((isset($_GET["action"])) && ($_GET["action"] == "deleted"))
                {
                echo'
                <div class="alert alert-success span8" style="margin-left:0px;">
                    Entrée supprimée avec succès <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }
				if ((isset($_GET["action"])) && ($_GET["action"] == "added"))
                {
                echo'
                <div class="alert alert-success span8" style="margin-left:0px;">
                    Mise à jour de l\'entrée effectuée avec succès <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }
                if ((isset($_GET["action"])) && ($_GET["action"] == "updated"))
                {
                echo'
                <div class="alert alert-success span8" style="margin-left:0px;">
                    Mise à jour de l\'entrée effectuée avec succès. <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }
				if ((isset($_GET["action"])) && ($_GET["action"] == "addedError"))
                {
                echo'
                <div class="alert alert-danger span8" style="margin-left:0px;">
                    opération non enregistré. reéssayez. <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }

            ?> 
        <div class="span9" id="content">
            <div class="row-fluid">
            <!-- block -->
            <div class="block">
              <div class="navbar navbar-inner block-header">
                <div class="muted pull-left span12">
                	<div class="span9">
             		<h5><?php echo 'Article : '.$REFARICLE.' <br>Designation : '.$DESIGNATION  ?></h5>
             		</div>
             		<div class="span3">
             			<a class="btn btn-primary btn-sm" href="add_entree.php?page=list_entree" style="float:right;width:200px;margin-bottom:20px;" >Ajouter une opération d'achat</a>
             		</div>	
                </div>
              </div>
              <div class="block-content collapse in">
                <div class="span12">
                    <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
                    <thead>
                      <tr>
                      	<th>Date opération</th>
                        <th>Qté Ajoutée</th>
				        <th>Fournisseur</th>
				        <th>Prix d'achat</th>						
				        <th></th>
                      </tr>
                    </thead>
                    <tbody>
                       <?php  while($row = mysql_fetch_object($result)){?>
                       	        
                      	<tr class="odd gradeX">
                      	<td><?php 
                            	/*$dateNewFormat = explode("/", $row->date_add);
                                echo $dateNewFormat[1].'/'.$dateNewFormat[0].'/'.$dateNewFormat[2];*/
                                echo $row->date_add;
                            ?>
                        </td>	
                        <td style="color:#d0343a;text-align:center;"><?php echo number_format($row->qte, 0, '', ' ')?></td>
        				<td><?php echo getFournisseur($row ->id_fournisseur)["raison_social"] ?> </td>
        				<td><?php echo number_format($row->prix, 3, '.', ' ');?></td>
						
						<td>
							<a href="view_entree.php?page=list_entree&id_entree=<?php echo $row->id_entree?>" data-toggle="modal" class="btn btn btn-small" style="margin-right:20px;">Consultation</a>
						   
							<a class="btn btn-primary btn-small"  href="edit_entree.php?action=update&page=list_entree&id_entree=<?php echo $row->id_entree?>"><i class="icon-pencil icon-white"></i></a>
						    <a href="#<?php echo $row->id_entree ?>myModal" data-toggle="modal"  class="btn btn-danger btn-small"><i class="icon-remove icon-white"></i></a>  
				        	
				        	<div id="<?php echo $row->id_entree ?>myModal" class="modal hide">
								<div class="modal-header">
									<button data-dismiss="modal" class="close" type="button">&times;</button>
										<p>Voulez-vous supprimer l'opération d'achat relative à l'article : <?php echo $REFARICLE; ?> </p>
									</div>
								
									<div class="modal-footer">
										<a class="btn btn-primary" href="submit/entree/delete_entree.php?action=delete&id_entree=<?php echo $row->id_entree?>&id_article=<?php echo $_GET["id_article"]?>&qt=<?php echo $row->qte ?>">Confirmer</a>
										<a data-dismiss="modal" class="btn" href="#">Annuler</a>
									</div>
							</div>
				        </td>
                      </tr>
                      <?php
                        }
                      ?>
                    </tbody>
                  </table>	
                </div>
                <a class="btn btn-primary btn-sm" href="add_entree.php?page=list_entree" style="float:right;width:200px;margin:20px;" >Ajouter une opération d'achat</a>
              </div>
            </div>
        <!-- /block -->
          </div>
                </div>
            </div>
            <hr>
        </div>
<?php  include("template/footer.php") ; ?>